<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>大嘿嘿后台管理</title>
		<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
		<script src="js/jquery-1.12.4.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
		
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/antd.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/axios-0.18.0.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/interfaceuRL.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
		  <form class="form-horizontal">

			<div class="form-group">
			  <label for="inputPassword3" class="col-sm-2 control-label">分类名称</label>
			  <div class="col-sm-10">
				  <input type="text" class="form-control" id="gname" :value="gname" >
			  </div>
			</div>
			<div class="form-group">
			  <label for="inputEmail3" class="col-sm-2 control-label">分类简介</label>
			  <div class="col-sm-10">
				<input type="text" class="form-control" id="detail" :value="detail" >
			  </div>
			</div>
			<div class="form-group">
			  <label for="inputEmail3" class="col-sm-2 control-label">分类标识</label>
			  <div class="col-sm-10">
				<input type="text" class="form-control" id="type" :value="type" >
			  </div>
			</div>
		    <div class="form-group">
		      <div class="col-sm-offset-2 col-sm-10">
		       <button type="button" @click="update()" class="btn btn-primary " >保存</button>
		      <button type="submit" class="btn btn-default" onclick="wenzgl.htlm" >取消</button>
		      </div>
		    </div>
		  </form>
		
			
		 </div>
		 
	</body>
</html>
<script type="text/javascript">
	var vm = new Vue({
		el: "#app",
		data: {
			gname:"",
			detail:"",
			type:"",
			superid:0,
			gid:0,
		},
		beforeMount:function(){
			var _this=this;
			_this.gid=window.location.href.split("?")[1].split("=")[1];
			axios({
			   //请求方式，'GET'或者'POST'
			    method: 'POST',
			    //请求地址
			    url: findCatelogId()+_this.gid,
			}).then(res => {
			     	console.log(res.data);
					
					_this.gname=res.data.gname;
					_this.detail=res.data.detail;
					_this.type=res.data.type;
					_this.superid=res.data.superid;
			}).catch(err => {
				alert("服务出错了!")
				
			  });
		},
		methods: {
			update: function() {
				if($("#gname").val()==""){
					alert("文章主题不能为空！！！")
				}else{
				axios({
					method:"POST",
					url:CatelogUpdate(),
					data:{
						"gname":$("#gname").val(),
						"detail":$("#detail").val(),
						"type":$("#type").val(),
						"superid":sessionStorage.getItem("superid"),
						"gid":this.gid,
					},

				}).then(res => {
					console.log(res.data);
					
					window.location.href="flguanli.html"
				}).catch(err => {
					alert("服务出错了！")
				})
				
				}			
			}
			
		},
		
	})
</script>
